<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let account = prompt('请输入您的账户');
      let mima = prompt('请输入您的密码');

      let loginList = [
        { userName: '1', password: '2' },
        { userName: 'zhangsan', password: 'zs321' },
        { userName: 'lisi', password: 'ls321' },
        { userName: 'yyqx', password: 'yyqx321' },
      ];

      let userInfo = {
        token1: {
          city: '杭州',
          money: '1000w',
          sex: '女',
          userName: 'admin',
          password: 'admin321',
        },
        token2: {
          city: '北京',
          money: '1100w',
          sex: '女',
          userName: 'zhangsan',
          password: 'zs321',
        },
        token3: {
          city: '北京',
          money: '800w',
          sex: '男',
          userName: 'lisi',
          password: 'ls321',
        },
        token4: {
          city: '天津',
          money: '600w',
          sex: '男',
          userName: 'yyqx',
          password: 'yyqx321',
        },
      };

      for (let i = 0; i < loginList.length; i++) {
        if (
          loginList[i].userName === account &&
          loginList[i].password === mima
        ) {  //登陆成功
          for (let k in userInfo) {
            let userInfo1 = [userInfo[k].city];
            let userInfo2 = [userInfo[k].money];
            let userInfo3 = [userInfo[k].sex];
            let userInfo4 = [userInfo[k].userName];
            for (let l = 0; l <= userInfo1.length; l++) {
              alert(`
              登陆成功，具体用户信息：

              city;${userInfo1[l]}
              money;${userInfo2[l]}
              sex;${userInfo3[l]}
              userName;${userInfo4[l]} 
                `);
              break;
            }
          }
          break;
        } else { //登录失败
          let arr = +prompt(`
          账号不存在:
          1,.注册账号
          2;直接退出
          `);
          if (arr === 2) break; //选择退出
          else if (arr === 1) {  //注册账号
            let arr1 = +prompt('请输入您注册的新账号');
            let arr2 = +prompt('请输入您设置的新密码');
            alert('您已经注册成功，去登录吧');
            for (;;) {  //循环登录
              let arr3 = +prompt('请输入您的账号');
              let arr4 = +prompt('请输入您的密码');
              if (arr1 === arr3 && arr2 === arr4) {
                alert('您已登陆成功');
              } else { //循环登录失败
                alert('再次输入错误，已经无机会，直接退出了');
                break;
              }
            }
            break;
          }
        }
      }
    </script>
  </body>
</html>
